<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>全局变量污染问题</title>
    <script src="test1.js"></script>
  </head>
  <body>
    <script>
      "use strict"; // 严格模式 不声明直接报 age is not defined
      let age = "男";
      Age();
      console.log(age);

      const HOST = {
        url: "https://www.liandongyun.com",
        port: "403",
      };
      HOST.port = "400";
      console.log(HOST);

      Object.freeze(HOST);

      // HOST.port='404'
      // console.table(HOST)
      // 如果冻结变量后，变量也不可以修改了，使用严格模式会报出错误。

      let aa = 1;
      let bb = aa;
      console.log(aa, bb);
      bb = 22;
      console.log(aa, bb);
      let obj = { name: "zhangsan" }; // 基本数据类型 传值
      let Obj = obj;
      console.log(Obj, obj);
      obj.name = "李四";
      console.log(Obj, obj); // 应用数据类型 传值

      let str = undefined; // 基本类型  let str = ''
      let user = null; // 引用类型   let user = {}

      function show(userName) {
        console.log(userName);
      }
      console.log(show());

      let num1 = 18;
      let num2;
      console.log(typeof num1);
      console.log(typeof num2);
      console.log(typeof num3);

      function star(starNum) {
        starNum = starNum || 5;
        for (var i = 0; i < starNum; i++) {
          console.log("^-^");
        }
      }
      star(10);

      // 严格模式详解
      let public1 = "公共的";
      console.log(public1);

      let strIct = "严格";
      console.log(strIct);

      let forIN = "外";
      function strICT() {
        forIN = "内";
      }
      strICT();
      console.log(forIN);
    </script>
  </body>
</html>
